
using System;

namespace PolicyAlgebra.Type
{
	///<summary>
	///    This class represents an item that has an attached comment.
	///    Used to attach comment to various types.
	///</summary>
	public abstract class Commentable : NamedAtom
	{
		private string comment;


		///<summary>
		/// The held comment.
		///</summary>
		///<returns>The held comment</returns>
		public string Comment
		{
			get
			{
				return comment;
			}
		}


		///<summary>
		/// Constructor.
		///</summary>
		///<param name="name">The name of this comment</param>
		public Commentable(string name) : this(name, "") {}


		///<summary>
		/// Constructor.
		///</summary>
		///<param name="name">The name of this comment</param>
		///<param name="comment">The comment to hold within this instance</param>
		public Commentable(string name, string comment) : base(name)
		{
			this.comment = comment;
		}


		///<summary>
		/// Transforms the instance to its corresponding textual form.
		///</summary>
		///<returns>The textual representation of this object</returns>
		public override string ToString()
		{
			string ret = base.ToString();

			if (comment != "")  
			{
				ret += "(" + comment + ")";
			}

			return ret;
		}
	}
}
